#include<bits/stdc++.h>
using namespace std;

struct node
{
    int d;
    int v;
    int a;
};
node car[100005];
struct kin
{
    int r;
    bool h = 0;
};
kin use[100005];

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin >> t;
    for(int k = 1; k <= t; k++)
    {
        int m,n,L,V;
        cin >> n >> m >> L >> V;
        for(int i = 1; i <= n; i++) cin >> car[i].d >> car[i].v >> car[i].a;
        for(int i = 1; i <= m; i++) cin >> use[i].r;
        cout << ceil(n * 1.0 / 2) << " " << ceil(m * 1.0 / 2) << endl;
    }
    return 0;
}
